<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    //生成器其实是一个特殊的函数
    //异步编程
    //函数代码的分割符
    function * gen(){
      console.log('111')
      yield '一只'
      console.log('222')
      yield '两只'
      console.log('333')
      yield '三只'
    }

    //调用
    // let iterator = gen()
    // console.log(iterator.next())
    // console.log(iterator.next())
    // console.log(iterator.next())

    //遍历
    for(let v of gen()){
      console.log(v)
    }

  </script>
</body>
</html>